#!/usr/bin/js

function FilaTabla(cols){
	this.cols = cols
	this.content = new Array(this.cols);
	this.setContent = setContent;
	this.printRows = printRows;
	
	function setContent(col, content){
		this.content[col] = content;
	}
	
	function printRows(){
		for(var i=0; i<this.cols; i++){
			print(marca("td")+this.content[i]+finmarca("td"));
		}
	}
}

function marca(m){
	return "<"+m+">";
}

function finmarca(m){ 
	return "</"+m+">";
}

function imprimirTabla(filas){
	print(marca('table'));
	
	for(var i in filas){
		print(marca('tr'));
		filas[i].printRows();
		print(finmarca('tr'));
	}
	print(finmarca('table'));
}

var contenido = "contenido de ejemplo";
var fila = new FilaTabla(5);
var filas = new Array(4);
for(var i=0; i<fila.cols; i++){
	fila.setContent(i, contenido);
}
for(var i=0; i<filas.length; i++){
	filas[i] = fila;
}
imprimirTabla(filas);